
import java.io.IOException;
import javax.microedition.media.Manager;
import javax.microedition.media.MediaException;
import javax.microedition.media.Player;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author khang
 */
public class Sound {
    private  Player slap,playerBomb,bmg;
    private  Player big_fart;
    public Sound(){
        try {
            slap = Manager.createPlayer(getClass().getResourceAsStream("/slap.wav"),"audio/X-wav");
            big_fart=Manager.createPlayer(getClass().getResourceAsStream("/big_fart.wav"),"audio/X-wav");
            //playerBomb = Manager.createPlayer(getClass().getResourceAsStream("/nep00.wav"),"audio/X-wav");
            //bmg = Manager.createPlayer(getClass().getResourceAsStream("/th06_02.mid"),"audio/midi");
            //playerBomb.realize();
            //slap.realize();
            //enemyDeath.realize();
            //bmg.realize();
            //bmg.setLoopCount(-1);
        } catch (IOException ex) {
            ex.printStackTrace();
        } catch (MediaException ex) {
            ex.printStackTrace();
        }
    }
    public void slapSound(){
        try {
        	slap.deallocate();
        	slap.realize();
            slap.start();
        } catch (MediaException ex) {
            ex.printStackTrace();
        }
    }
    public void bigFartSound(){
        try {
        	big_fart.deallocate();
        	big_fart.realize();
            big_fart.start();
        } catch (MediaException ex) {
            ex.printStackTrace();
        }
    }
    public void playerBombSound(){
        try {
            //playerBomb.setLoopCount(4);
            playerBomb.start();
        } catch (MediaException ex) {
            ex.printStackTrace();
        }
    }
    public void bakcgroundSoundStart(){
        try {            
            bmg.start();
        } catch (MediaException ex) {
            ex.printStackTrace();
        }
    }
    public void bakcgroundSoundStop(){
        try {            
            bmg.stop();
        } catch (MediaException ex) {
            ex.printStackTrace();
        }
    }
}

